
<!-- src/components/Navbar.vue -->
<template>
  <el-menu
      :default-active="activeIndex"
      class="el-menu-demo"
      mode="horizontal"
      @select="handleSelect"
      background-color="#217ECC"
      text-color="#FFFFFF"
      active-text-color="#FFD700"
  >
    <div class="menu-left">
      <el-menu-item index="2" class="menu-item">项目管理</el-menu-item>
      <el-menu-item index="3" class="menu-item">财务记账</el-menu-item>
    </div>
    <div class="navbar-right">
      <el-button
          circle
          @click="handleLockScreen"
          :icon="Lock"
          class="lock-button"
      >
      </el-button>
    </div>
  </el-menu>
</template>

<script setup>import { ref } from 'vue'
import { useRouter } from 'vue-router'
import { ElMessageBox } from 'element-plus'
import { Lock } from '@element-plus/icons-vue'

const activeIndex = ref('2')
const router = useRouter()

const handleSelect = (key) => {
  activeIndex.value = key
  switch (key) {
    case '2':
      router.push('/resource-management')
      break
    case '3':
      // TODO: 跳转到财务记账页面
      console.log('财务记账功能待实现')
      break
    default:
      router.push('/')
  }
}

const handleLockScreen = () => {
  // 用户确认锁屏，跳转到登录页面
  router.push('/')
}
</script>

<style scoped>.el-menu-demo {
  width: 100%;
  display: flex;
  background-color: #217ECC;
  justify-content: space-between;
  padding: 0;
  margin: 0;
  align-items: center;
}

.menu-left {
  display: flex;
  align-items: center;
}

.navbar-right {
  display: flex;
  align-items: center;
  padding-right: 20px;
}

.lock-button {
  background-color: #217ECC;
  border: 1px solid #FFFFFF;
  color: #FFFFFF;
  width: 32px;
  height: 32px;
}

.lock-button:hover {
  background-color: #1a67a3;
  border-color: #FFD700;
  color: #FFD700;
}

.menu-item {
  font-size: 18px;
  font-weight: bold;
  color: #FFFFFF;
  border-bottom: none !important;
}

:deep(.el-menu-item) {
  font-size: 18px;
  font-weight: bold;
  color: #FFFFFF;
  float: left;
}

:deep(.el-menu-item.is-active) {
  color: #FFD700;
  border-bottom: 2px solid #FFD700 !important;
}

/* 移除菜单项之间的右边距 */
:deep(.el-menu-item) {
  margin-right: 0;
}
</style>